package com.itheima.strengthen.test02.controller;

import com.itheima.strengthen.test02.dao.jiutongDao;
import com.itheima.strengthen.test02.domain.Cask;
import com.itheima.strengthen.test02.domain.NuoZhou;
import com.itheima.strengthen.test02.domain.Skills;
import com.itheima.strengthen.test02.service.jiutongService;

import java.util.Random;

public class jiutongController {
    static jiutongService jiutongService = new jiutongService();
    Random random = new Random();

    public Cask mpAttributeChange(Skills skills){
        return jiutongService.mpAttributeChange(skills);
    }

    public Cask hpAtrributeChange(Skills skills) {
        return jiutongService.hpAtrributeChange(skills);
    }

    public void sendAtrribute(Cask jiuTong) {
        jiutongService.sendAtrribute(jiuTong);
    }

    public Cask hpAtrributeChange(double hAttack) {
        return jiutongService.hpAtrributeChange(hAttack);
    }


    public Skills attack(Cask jiuTong) {
        while (true){
            //随机抽取三个技能进行攻击
            int choice = random.nextInt(4) + 1;//1-4
            if (choice  == 1){
                int sMp = jiuTong.getqSkill().getsMp();
                //判断蓝量是否足够
                if (sMp <= jiuTong.gethMp()){
                    return jiuTong.getqSkill();
                }else{

                }
            }else if (choice == 2){
                int sMp = jiuTong.getwSkill().getsMp();
                if(sMp <= jiuTong.gethMp()){
                    return jiuTong.getwSkill();
                }else {

                }
            }else if (choice == 3){
                int sMp = jiuTong.geteSkill().getsMp();
                if(sMp <= jiuTong.gethMp()){
                    return jiuTong.geteSkill();
                }else {

                }
            }else {
                return null;
            }
        }
    }
}
